package com.myproject.filmrecommendationsys.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.myproject.filmrecommendationsys.util.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.myproject.filmrecommendationsys.domain.Banner;
import com.myproject.filmrecommendationsys.service.IBannerService;


/**
 * 轮播图Controller
 */
@RestController
@RequestMapping("/banner")
@Api(tags = "轮播图管理")
public class BannerController
{
    @Autowired
    private IBannerService bannerService;

    /**
     * 查询轮播图列表
     */

    @GetMapping("/list")
    @ApiOperation("查询轮播图列表")
    public AjaxResult list(Banner banner)
    {
        return AjaxResult.success(bannerService.selectBannerList(banner));
    }

    /**
     * 获取轮播图详细信息
     */

    @GetMapping(value = "/{id}")
    @ApiOperation("获取轮播图详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(bannerService.selectBannerById(id));
    }

    /**
     * 新增轮播图
     */

    @PostMapping("/add")
    @ApiOperation("新增轮播图")
    public AjaxResult add(@RequestBody Banner banner)
    {
        return AjaxResult.success(bannerService.insertBanner(banner));
    }

    /**
     * 修改轮播图
     */

    @PutMapping("/update")
    @ApiOperation("修改轮播图")
    public AjaxResult edit(@RequestBody Banner banner)
    {
        return AjaxResult.success(bannerService.updateBanner(banner));
    }

    /**
     * 删除轮播图
     */

	@DeleteMapping("/{ids}")
    @ApiOperation("删除轮播图")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return AjaxResult.success(bannerService.deleteBannerByIds(ids));
    }
}
